package com.hxtec.polaris.commons.dto;

import lombok.Getter;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * @Describtion 物流信息映射
 * @Author yonyong
 * @Date 2019/12/26 11:15
 * @Version 1.0.0
 **/
@Getter
public class ExpressDto {
    private String time;
    private String desc;

    public void setTime(long time) {
        this.time = secondToDate(time,"yyyy-MM-dd hh:mm:ss");
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }
    /**
     * 秒转换为指定格式的日期
     * @param second
     * @param patten
     * @return
     */
    private String secondToDate(long second,String patten) {
        Calendar calendar = Calendar.getInstance();
        //转换为毫秒
        calendar.setTimeInMillis(second * 1000);
        Date date = calendar.getTime();
        SimpleDateFormat format = new SimpleDateFormat(patten);
        String dateString = format.format(date);
        return dateString;
    }
}
